package com.lyw.aop.proxy;

//import org.aopalliance.intercept.MethodInterceptor;

//import org.springframework.cglib.proxy.MethodInterceptor;
//import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

/**
 * --add-opens java.base/java.lang=ALL-UNNAMED
 */
public class CGlibMethodInterceptor implements MethodInterceptor {
    private Object target;

    public CGlibMethodInterceptor(Object target) {
        this.target = target;
    }

    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        System.out.println("我开始代理");
        Object invoke = method.invoke(target, args);
        System.out.println("我结束代理");
        return invoke;
    }
}
